import React, { Component } from "react";
import Props from "prop-types";

export default class NavBar extends Component {
  state = {};
  //   校验
  // 推荐这种写法,因为是在类的内部,想要访问需要加static,静态资源
  static propTypes = {
    content: Props.string,
    leftShow: Props.bool,
    rightShow: Props.bool,
  };
  //   默认值;
  static defaultProps = {
    content: "内容",
    leftShow: true,
    rightShow: true,
  };

  render() {
    let { content, leftShow, rightShow } = this.props;
    return (
      <section>
        <div className="navbar">
          {leftShow ? <div>返回</div> : "0"}
          <div>{content}</div>
          {rightShow ? <div>回到首页</div> : "0"}
        </div>
      </section>
    );
  }
}
// 第二种写法
// // 校验
// NavBar.propTypes = {
//   content: Props.string,
//   leftShow: Props.bool,
//   rightShow: Props.bool,
// };
// // 默认值
// NavBar.defaultProps = {
//   content: "内容",
//   leftShow: true,
//   rightShow: true,
// };
